<template>
  <div class="hot-nav">
    <div class="hot-nav-name" :class="changeNavIndex === index ? 'active' : ''" @click="navHandler(index,item)" v-for="(item,index) in navLists" :key="index">{{item}}</div>
  </div>
</template>
<script>
export default {
  props:{
    //导航
    navLists:Array
  },
  data () {
    return {
      //切换导航的状态,全部的id为-1
      changeNavIndex:0,
    }
  },
  methods:{
    //切换导航的状态
    navHandler(index,name){
      this.changeNavIndex = index;
      this.$emit("sendNavHandler",name)
      if(name==="全部"){
        name ="";
      }
      this.$emit("sendNavHandler",name)
    },
  }
}
</script>

<style scoped>
 /* 导航 */
.hot-nav{
  display:flex;
  flex-wrap:wrap;
  padding-left:28px;
  border:2px solid #383a43;
  border-radius:4px;
  box-sizing:border-box;
  color:#666666;
}
.hot-nav-name{
  height:55px;
  line-height: 55px;
  margin-right:20px;
  cursor:pointer;
  user-select:none;
  transition:all .2s ease;
}
.hot-nav-name:hover{
  color:#ffffff;
}
.hot-nav .active{
  color:#ffffff;
}
</style>
